<?php

namespace app\common\model;

use think\Model;

class Subject extends Model
{
    // 表名
    protected $name = 'subject';
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    // 定义时间戳字段名
    protected $createTime = 'created_at';
    protected $updateTime = false;

    public static $type_list = [
        '1' => '行政班级',
        '2' => '走班班级',
    ];

    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : $data['type'];
        return isset(static::$type_list[$value]) ? static::$type_list[$value] : '';
    }

    public function school()
    {
        return $this->belongsTo('School');
    }
}